'''

Copyright 2010 Manuel Reinelt

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Created on 12.04.2010

@author: Manuel Reinelt
contact: mrdevlab@googlemail.com

'''

import os
import platform
import zipfile
import sys

def check_input_file(filename,verbose):
    '''
    checks if an input file exists and if it is
    zip compressed. 
    returns filesize and bool zip
    '''
     
    filename = os.path.abspath(filename)
    filesize = 0
    zip = False     
       
    if verbose:
        print "checking inputfile " + filename

    if not os.path.isfile(filename):
        print "ERROR: inputfile: " + filename + " not found, exiting"
        sys.exit(-1)
    else:    
        filesize = os.path.getsize(filename)
        try:
            if zipfile.is_zipfile(filename):
                zip = True
                if verbose:
                    print "zip-compression detected"
            return filesize, zip
        except:
            print "ERROR: corrupted zipfile detected, exiting"
            sys.exit(-1)
    

     
         
                
        